(function($){
    function Upload__(option){
        this.option = option = $.extend({},Upload__.default,option)
        this.bind()
    }
    Upload__.default ={
        el:"",
        url:"",
        isImg:true,
        success:function(data){
        },
        type:"post",
    }
    Upload__.prototype = {
        bind:function(){
            if(!this.option.url || !this.option.el){
                console.error("no url or el")
                return false
            }
            $(this.option.el).click(function(){
                
                $("#ffffff").remove()
                $("body").append("<form id='ffffff'><input type='file' name='file' "+ (this.option.isImg? "accept='image/*'" : "") +" style='display:none'></from>")
                $("#ffffff input").click()
            }.bind(this))
            var that = this
            $(document).on("change","#ffffff input",function(){
                that.send()
                
            })
        },
        send:function(){
            var data = new FormData($("#ffffff")[0])
            $.ajax({
                url: this.option.url,
                type: this.option.type,
                data: data,
                asyne:false,
                processData: false,  
                contentType: false,   
                
                success:this.option.success,
                beforeSend:function(){
                    $("#ffffff").remove()
                }
            });
        },
    }
    $.extend({
        up:function(op){
            
            new Upload__(op)
        }
    })
})(jQuery)